/**
 * <copyright>
 * </copyright>
 *

 */
package br.ufrn.dimap.processDsl.impl;

import br.ufrn.dimap.processDsl.Artifact;
import br.ufrn.dimap.processDsl.Discipline;
import br.ufrn.dimap.processDsl.ProcessDslPackage;
import br.ufrn.dimap.processDsl.Role;
import br.ufrn.dimap.processDsl.Task;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Process</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getName <em>Name</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getDisciplines <em>Disciplines</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getRoles <em>Roles</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getArtifacts <em>Artifacts</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getTasks <em>Tasks</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getGuidances <em>Guidances</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.ProcessImpl#getLifecyleElement <em>Lifecyle Element</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProcessImpl extends MinimalEObjectImpl.Container implements br.ufrn.dimap.processDsl.Process
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getDisciplines() <em>Disciplines</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDisciplines()
   * @generated
   * @ordered
   */
  protected EList<Discipline> disciplines;

  /**
   * The cached value of the '{@link #getRoles() <em>Roles</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRoles()
   * @generated
   * @ordered
   */
  protected EList<Role> roles;

  /**
   * The cached value of the '{@link #getArtifacts() <em>Artifacts</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArtifacts()
   * @generated
   * @ordered
   */
  protected EList<Artifact> artifacts;

  /**
   * The cached value of the '{@link #getTasks() <em>Tasks</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTasks()
   * @generated
   * @ordered
   */
  protected EList<Task> tasks;

  /**
   * The cached value of the '{@link #getGuidances() <em>Guidances</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGuidances()
   * @generated
   * @ordered
   */
  protected EList<EObject> guidances;

  /**
   * The cached value of the '{@link #getLifecyleElement() <em>Lifecyle Element</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLifecyleElement()
   * @generated
   * @ordered
   */
  protected EList<EObject> lifecyleElement;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ProcessImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ProcessDslPackage.Literals.PROCESS;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.PROCESS__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Discipline> getDisciplines()
  {
    if (disciplines == null)
    {
      disciplines = new EObjectContainmentEList<Discipline>(Discipline.class, this, ProcessDslPackage.PROCESS__DISCIPLINES);
    }
    return disciplines;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Role> getRoles()
  {
    if (roles == null)
    {
      roles = new EObjectContainmentEList<Role>(Role.class, this, ProcessDslPackage.PROCESS__ROLES);
    }
    return roles;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Artifact> getArtifacts()
  {
    if (artifacts == null)
    {
      artifacts = new EObjectContainmentEList<Artifact>(Artifact.class, this, ProcessDslPackage.PROCESS__ARTIFACTS);
    }
    return artifacts;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Task> getTasks()
  {
    if (tasks == null)
    {
      tasks = new EObjectContainmentEList<Task>(Task.class, this, ProcessDslPackage.PROCESS__TASKS);
    }
    return tasks;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<EObject> getGuidances()
  {
    if (guidances == null)
    {
      guidances = new EObjectContainmentEList<EObject>(EObject.class, this, ProcessDslPackage.PROCESS__GUIDANCES);
    }
    return guidances;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<EObject> getLifecyleElement()
  {
    if (lifecyleElement == null)
    {
      lifecyleElement = new EObjectContainmentEList<EObject>(EObject.class, this, ProcessDslPackage.PROCESS__LIFECYLE_ELEMENT);
    }
    return lifecyleElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case ProcessDslPackage.PROCESS__DISCIPLINES:
        return ((InternalEList<?>)getDisciplines()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.PROCESS__ROLES:
        return ((InternalEList<?>)getRoles()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.PROCESS__ARTIFACTS:
        return ((InternalEList<?>)getArtifacts()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.PROCESS__TASKS:
        return ((InternalEList<?>)getTasks()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.PROCESS__GUIDANCES:
        return ((InternalEList<?>)getGuidances()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.PROCESS__LIFECYLE_ELEMENT:
        return ((InternalEList<?>)getLifecyleElement()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ProcessDslPackage.PROCESS__NAME:
        return getName();
      case ProcessDslPackage.PROCESS__DISCIPLINES:
        return getDisciplines();
      case ProcessDslPackage.PROCESS__ROLES:
        return getRoles();
      case ProcessDslPackage.PROCESS__ARTIFACTS:
        return getArtifacts();
      case ProcessDslPackage.PROCESS__TASKS:
        return getTasks();
      case ProcessDslPackage.PROCESS__GUIDANCES:
        return getGuidances();
      case ProcessDslPackage.PROCESS__LIFECYLE_ELEMENT:
        return getLifecyleElement();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ProcessDslPackage.PROCESS__NAME:
        setName((String)newValue);
        return;
      case ProcessDslPackage.PROCESS__DISCIPLINES:
        getDisciplines().clear();
        getDisciplines().addAll((Collection<? extends Discipline>)newValue);
        return;
      case ProcessDslPackage.PROCESS__ROLES:
        getRoles().clear();
        getRoles().addAll((Collection<? extends Role>)newValue);
        return;
      case ProcessDslPackage.PROCESS__ARTIFACTS:
        getArtifacts().clear();
        getArtifacts().addAll((Collection<? extends Artifact>)newValue);
        return;
      case ProcessDslPackage.PROCESS__TASKS:
        getTasks().clear();
        getTasks().addAll((Collection<? extends Task>)newValue);
        return;
      case ProcessDslPackage.PROCESS__GUIDANCES:
        getGuidances().clear();
        getGuidances().addAll((Collection<? extends EObject>)newValue);
        return;
      case ProcessDslPackage.PROCESS__LIFECYLE_ELEMENT:
        getLifecyleElement().clear();
        getLifecyleElement().addAll((Collection<? extends EObject>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ProcessDslPackage.PROCESS__NAME:
        setName(NAME_EDEFAULT);
        return;
      case ProcessDslPackage.PROCESS__DISCIPLINES:
        getDisciplines().clear();
        return;
      case ProcessDslPackage.PROCESS__ROLES:
        getRoles().clear();
        return;
      case ProcessDslPackage.PROCESS__ARTIFACTS:
        getArtifacts().clear();
        return;
      case ProcessDslPackage.PROCESS__TASKS:
        getTasks().clear();
        return;
      case ProcessDslPackage.PROCESS__GUIDANCES:
        getGuidances().clear();
        return;
      case ProcessDslPackage.PROCESS__LIFECYLE_ELEMENT:
        getLifecyleElement().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ProcessDslPackage.PROCESS__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case ProcessDslPackage.PROCESS__DISCIPLINES:
        return disciplines != null && !disciplines.isEmpty();
      case ProcessDslPackage.PROCESS__ROLES:
        return roles != null && !roles.isEmpty();
      case ProcessDslPackage.PROCESS__ARTIFACTS:
        return artifacts != null && !artifacts.isEmpty();
      case ProcessDslPackage.PROCESS__TASKS:
        return tasks != null && !tasks.isEmpty();
      case ProcessDslPackage.PROCESS__GUIDANCES:
        return guidances != null && !guidances.isEmpty();
      case ProcessDslPackage.PROCESS__LIFECYLE_ELEMENT:
        return lifecyleElement != null && !lifecyleElement.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //ProcessImpl
